<?php
/**
* 
* Ausgabe einer Html Tabelle
* 
* 
*/

class html_table
    {
    public $table = "";
    public $search = "";
    
    public $field = "";

    public $tableClass = "";

    public $tableCaption = "";

    function display()
        {

        $data=new data();
        $data->table=$this->table;
        
        
        if ($this->field !== "") {
            $field = general::stringToArray($this->field);
            
        } else {
            
            $field = db::getTableFieldArray($this->table);
            
        }
        

        $html='<table width="200" border="1">';

        /*<caption>
    this is a table
  </caption>*/


        
          $html = $html . '<tr>';
          
          
        
         foreach ($field as $fieldItem)
                {
                $html=$html . '<th scope="col">' . $fieldItem . '</th>';
                               
                
                }
        
        
        $html = $html . '</tr>';
        
        
        
        

        foreach ($data->getData() as $dataItem)
            {

            $html = $html . '<tr>';

            //print_r($dataItem);
            
            foreach ($field as $fieldItem)
                {
                $html=$html . '<td>' . $dataItem[$fieldItem] . '</td>';
                
                //print_r($dataItemField);
                //echo "---------";
                
                }

            $html=$html . '</tr>';
            }

        $html=$html . '</table>';
        
        return $html;
        
        }
    }
?>